public class j111902 {
    public static void main(String[] args) throws InterruptedException {
        Object lockerA = new Object();
        Object lockerB = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (lockerA) {
                System.out.println("t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (lockerB) {
                    System.out.println("t2");
                }
            }
        }
        );
        Thread t2 = new Thread(() -> {
            synchronized (lockerB) {
                System.out.println("t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (lockerA) {
                    System.out.println("t2");
                }
            }
        }
        );
        t1.start();
        t2.start();
    }
}
